package com.maila.xiaoaoschool.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.maila.xiaoaoschool.R;
import com.maila.xiaoaoschool.adapter.CommentAdapter;
import com.maila.xiaoaoschool.widget.NoScrollListView;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/9/27.
 */

public class FoodDetailActivity extends AppCompatActivity {
    @BindView(R.id.iv_food)
    ImageView ivFood;
    @BindView(R.id.btn_cancel)
    AutoRelativeLayout btnCancel;
    @BindView(R.id.iv_collect)
    ImageView ivCollect;
    @BindView(R.id.btn_collect)
    AutoRelativeLayout btnCollect;
    @BindView(R.id.tv_food_name)
    TextView tvFoodName;
    @BindView(R.id.tv_food_xiaoliang)
    TextView tvFoodXiaoliang;
    @BindView(R.id.tv_fee)
    TextView tvFee;
    @BindView(R.id.btn_add_to_car)
    TextView btnAddToCar;
    @BindView(R.id.tv_comment_count)
    TextView tvCommentCount;
    @BindView(R.id.lv_comment)
    NoScrollListView lvComment;
    int iscollect = 0;
    CommentAdapter commentAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_food_details);
        ButterKnife.bind(this);
        commentAdapter = new CommentAdapter(this);
        lvComment.setAdapter(commentAdapter);
    }

    @Override
    protected void onResume() {
        super.onResume();
        requestViewFoucus(ivFood);
    }

    private void requestViewFoucus(View view) {
        view.setFocusable(true);
        view.setFocusableInTouchMode(true);
        view.requestFocus();
    }
    @OnClick({R.id.btn_cancel, R.id.btn_collect, R.id.btn_add_to_car})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_cancel:
                finish();
                break;
            case R.id.btn_collect:
                if (iscollect == 1) {
                    iscollect=0;
                    ivCollect.setImageResource(R.mipmap.weishoucang);
                } else {
                    iscollect=1;
                    ivCollect.setImageResource(R.mipmap.shoucanghong);
                }
                break;
            case R.id.btn_add_to_car:
                break;
        }
    }
}
